home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / SUPPRESS.ASM < prev    next >
Assembly Source File  |  1987-03-12  |  13KB  |  479 lines

  1.  
  2. ; NOTE : This template is for .COM files only do not use for .EXE files!!
  3.  
  4.  
  5. ;
  6. ;
  7. ;
  8. ;       Copyright 1986 by Dana Nowell - All rights reserved
  9. ;
  10. ; HISTORY:
  11. ;     Version     Date         Name            Description
  12. ;       1.0     11/10/86        dn      first cut
  13. ;       1.01    11/11/86        dn      masked all foreground colors
  14. ;                                       either on or off
  15. ;       1.02    11/14/86        dn      masked all background colors
  16. ;                                       either on or off
  17. ;       1.03    11/22/86        dn      added check for already resident
  18. ;       1.04    11/23/86        dn      fixed bug with black on black displays
  19. ;       1.05    11/30/86        dn      set color suppressed mode at install
  20. ;                                       incase program checks.
  21. ;                                       moved copyright message to after
  22. ;                                       equipment check call so monochrome
  23. ;                                       can be properly determined
  24. ;       1.06    12/27/86        dn      trapped for pixel and tty writes
  25. ;                                       moved color remap to a subroutine
  26. ;                                       added mode variable to trap for
  27. ;                                       graphics mode differences
  28. ;       1.07    03/12/87        dn      trapped for dark grey on black
  29. ;
  30.  
  31. title   SUPPRESS.ASM
  32.  
  33.  
  34.  
  35.         NULL            equ     00h
  36.         BELL            equ     07h             ; bell character
  37.         BACKSPACE       equ     08h             ; backspace character
  38.         TAB             equ     09h             ; tab character
  39.         LF              equ     0ah             ; line feed
  40.         F_FEED          equ     0ch             ; form feed
  41.         CR              equ     0dh             ; carriage return
  42.         EOF             equ     1ah             ; ctrl z ( end of file )
  43.         SPACE           equ     ' '             ; ascii space character
  44.         QUOTE           equ     '"'
  45.  
  46. SIGNATURE1              equ     6144h           ; used for already
  47. SIGNATURE2              equ     616eh           ; resident check
  48.  
  49. DOS_INT                 equ     21h      ; DOS function interrupt
  50. DISP_CHAR               equ     02h
  51. GET_KEY                 equ     08h
  52. DOS_SCR_MSG             equ     09h
  53. DOS_SET_INT             equ     25h
  54. DOS_RESIDENT            equ     31h
  55. DOS_GET_INT             equ     35h
  56. DOS_TERMINATE           equ     4ch
  57. DOS_STRING_TERM         equ     '$'
  58. BIOS_ACTIVE_PAGE        equ      5
  59. BIOS_SET_VIDEO_MODE     equ      0
  60. BIOS_SET_CURSOR_SIZE    equ      1
  61.  
  62. ; Interrupt vectors used
  63.  
  64. HOOK_INT        equ    10h      ; interrupt to be hooked
  65. PAGE_NUMBER     equ     0       ; active page to be set if color moniter
  66. VIDEO_MODE      equ     2       ; color 80 x 25 with 4 grey colors
  67. CURSOR_SIZE     equ  0607h      ; color monitor cursor 6x7
  68.  
  69. ;------------------------------------------------------------------------------
  70. ;
  71. ;       MACRO   SECTION
  72. ;
  73. ;------------------------------------------------------------------------------
  74.  
  75. Version_msg     macro
  76.                 jmp     short copyright_end
  77.  
  78. copyright_msg   db      CR, LF
  79.                 db      'SUPPRESS - Version 1.07', CR, LF
  80.                 db      'Copyright 1986, Dana Nowell  ', CR, LF, CR, LF
  81.                 db      'May be distributed without license', CR, LF, '$'
  82. copyright_end:
  83.                 Msg     copyright_msg
  84.                 endm
  85.  
  86.  
  87. Msg     macro   ptr
  88.  
  89.         push    dx
  90.         push    ax
  91.  
  92.         lea     dx, ptr
  93.         mov     ah, 09h
  94.         int     21h
  95.  
  96.         pop     ax
  97.         pop     dx
  98.  
  99.         endm
  100.  
  101.  
  102.  
  103.  
  104.  
  105. com     segment para public 'code'
  106.         assume cs:com, ds:com, es:com
  107.  
  108.  
  109.         org     100h    ; required for COM file ( skips PSP )
  110.  
  111.  
  112. start:
  113.         jmp     install                 ; install the demon
  114.  
  115. ;-------------------------------------------------------------------
  116. ;
  117. ;               resident data structures go here
  118. ;
  119. ;-------------------------------------------------------------------
  120.  
  121.         old_int         dd      0       ; original value of hooked interrupt
  122.         resident1       dw      SIGNATURE1
  123.         resident2       dw      SIGNATURE2
  124.         mode            dw      0       ; 0 = text  -  1 = graphics
  125.  
  126.  
  127. ;-------------------------------------------------------------------
  128. ;
  129. ;               new interrupt starts here
  130. ;
  131. ;-------------------------------------------------------------------
  132.  
  133.  
  134. new_int:
  135.         pushf
  136.  
  137.         cmp     ah, 0eh
  138.         je      write_tty
  139.  
  140.         cmp     ah, 9
  141.         je      write_character
  142.  
  143.         cmp     ah, 0ah
  144.         je      write_attribute
  145.  
  146.         cmp     ah, 6
  147.         je      scroll
  148.  
  149.         cmp     ah, 7
  150.         je      scroll
  151.  
  152.         cmp     ah, 0ch
  153.         je      write_pixel
  154.  
  155.         cmp     ah, 13h
  156.         je      write_string
  157.  
  158.         cmp     ah, 0
  159.         je      set_mode
  160.  
  161.         jmp     do_int
  162.  
  163. write_pixel:
  164.  
  165.         push    bx              ; save bx
  166.         mov     bl, al          ; pixel color is in al so move in to bl
  167.         call    remap_color     ; remap the pixel color
  168.         mov     al, bl          ; put color back into al
  169.         pop     bx              ; restore original bx
  170.  
  171.         jmp     do_int
  172.  
  173. write_tty:
  174.  
  175.         call    remap_color     ; attribute in bl
  176.         jmp     do_int
  177.  
  178.  
  179. write_character:
  180.  
  181.         call    remap_color     ; not mixed - attribute in bl
  182.         jmp     do_int
  183.  
  184.  
  185.  
  186. write_string:
  187.  
  188.         cmp     al, 1
  189.         jg      mixed_attributes ; attribute bytes and chars mixed in a string
  190.  
  191.         call    remap_color     ; not mixed - attribute in bl
  192.         jmp     do_int
  193.  
  194. mixed_attributes:               ; stub for now
  195.         jmp     do_int
  196.  
  197.  
  198.  
  199.  
  200. scroll:
  201.         and     bh, 8fh         ; set blank lines to black
  202.         jmp     do_int
  203.  
  204.  
  205.  
  206.  
  207. set_mode:
  208.         mov     cs:mode, 0         ; mark as text mode
  209.         cmp     al, 4
  210.         jl      text
  211.  
  212.         mov     cs:mode, 1         ; really graphics mode
  213.         cmp     al, 5
  214.         jle     mgraphics
  215.         jmp     do_int
  216.  
  217. text:
  218.         cmp     al, 1
  219.         jg      htext
  220.  
  221. ltext:
  222.         mov     al, 0
  223.         jmp     do_int
  224.  
  225. htext:
  226.         mov     al, 2
  227.         jmp     do_int
  228.  
  229. mgraphics:
  230.         mov     al, 5
  231.         jmp     do_int
  232.  
  233.  
  234.  
  235.  
  236.  
  237. write_attribute:
  238.  
  239.         call    remap_color
  240.  
  241.  
  242. ;-------------------------------------------------------------------
  243. ;
  244. ;               be well behaved and pass control to original int
  245. ;
  246. ;-------------------------------------------------------------------
  247.  
  248. do_int:
  249.         popf
  250.         pushf
  251.         call   dword ptr cs:old_int     ; do old interrupt
  252.  
  253.         iret                            ; bye bye
  254.  
  255.  
  256.  
  257. remap_color     proc    near
  258.  
  259.         push    dx
  260.         push    bx
  261.  
  262. ;       test   bl, 08h
  263. ;       jz     not_grey
  264. ;
  265. ;       push   bx
  266. ;       and    bl, 77h
  267. ;       pop    bx
  268. ;       jnz    not_grey
  269.  
  270.         cmp     bl, 88h
  271.         je      grey
  272.  
  273.         cmp     bl, 08h
  274.         jne     not_grey
  275.  
  276. grey:
  277.         pop     bx
  278.         or      bl, 01h
  279.         push    bx
  280.  
  281. not_grey:
  282.         mov     dl, 00h         ; assume black background, black characters
  283.  
  284.         and     bl, 77h         ; AND color and background in character
  285.         jz      black           ; no color or background - so use default
  286.  
  287.         mov     dl, 70h         ; assume color background, black characters
  288.  
  289.         and     bl, 07h         ; and color in character
  290.         jz      black           ; no color - so use color background
  291.  
  292.         mov     dl, 07h         ; assume black background, color characters
  293.  
  294.         pop     bx              ; restore original bx
  295.         and     bl, 8fh         ; set background off leave colors on and
  296.                                 ; attributes as before ( blink & intensity )
  297.         push    bx              ; set-up for next pop
  298.  
  299. black:
  300.         pop     bx
  301.         or      bl, dl          ; mask it for readability
  302.